Skip to content

refactor(repo-fleet-hygiene): simplify apply-plan.sh decision recording - #15167

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14709-42884770773-1
Nov 10, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14709-42884770773-1

Conversation

@melodic-automation-lanes

@melodic-automation-lanes melodic-automation-lanes Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Refs: #14709

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Simplified plugins/repo-fleet-hygiene/skills/apply/scripts/apply-plan.sh without changing behavior. A decide helper now records each refresh decision from the caller's unit fields, replacing 27 copies of the 11-argument append_decision call. In the embedded Python, lookup tables replace the phase and allowed-kind if-chains, and the output row is built from one list. The script is 43 lines shorter. Choice and basis: the other four listed files (fleet-discovery.sh, scope-resolve.sh, worktree-root-resolve.sh, worktree-root-legacy.sh) are left unchanged. scripts/cross-plugin-source-registry.txt:187-207 registers each one as a byte-identical copy shared with plugins/source-control/scripts/, and for the two worktree-root files the canonical copy lives in source-control. Any edit to them would have to be mirrored into plugins/source-control, which the issue's acceptance criteria rule out (the diff edits only the listed files) and its out-of-scope list sets aside (no cross-file work, no files from other chunks). They are listed in remaining so the PR refs the issue instead of closing it.

Remaining work

  • Simplify plugins/repo-fleet-hygiene/scripts/fleet-discovery.sh and scope-resolve.sh together with their byte-identical copies in plugins/source-control/scripts/ (repo-fleet-hygiene holds the canonical copy, per scripts/cross-plugin-source-registry.txt)
  • Simplify plugins/repo-fleet-hygiene/scripts/worktree-root-resolve.sh and worktree-root-legacy.sh by editing their canonical copies in plugins/source-control/scripts/ and copying them back (worktree-root-legacy.sh is due for deletion after 2026-12-31)

Not verified

  • plugins/repo-fleet-hygiene/skills/apply/scripts/apply-plan.test.sh was not run: the lane offers no way to run a test suite, so it is left to the PR's CI
  • shellcheck was not run directly on apply-plan.sh. The review subagent reasoned that no new SC2154/SC2034/SC2311 warning appears, and CI lint confirms
  • tidy skipped passes 4 and 5 (markdown) on the changelog fragment, whose body is the exact text the issue requires. Passes 1 to 3 ran and changed nothing
  • the four shared-copy files were reviewed but not edited, since each is a registered byte-identical cross-plugin copy whose edit would need a matching edit in plugins/source-control/scripts/ (see summary)

Fix

  • plugins/repo-fleet-hygiene/skills/apply/scripts/apply-plan.sh: added a decide() helper that calls append_decision with the caller's phase/op/canonical/ref/kind/target/expected, and used it in refresh_branch_delete, refresh_worktree_cleanup and the unknown-operation arm. The tail of…
  • .changes/repo-fleet-hygiene/work-resolve-issue-issue-14709-42884770773-1-42896a08.md: new patch fragment for repo-fleet-hygiene, made with new-changelog-fragment, body ### Changed / - Internal simplification, no behavior change.

Verification

The runner ran each check from the base copy against 7eda1d6:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • .lane/checks/bin/check-changelog-fragments: all 9 changelog fragments valid (ran before and after tidy)
  • .lane/checks/bin/check-changed-skills: CHECK-SKILL apply PASS, 0 errors, 2 warnings that predate this change (description length, no Gotchas surface)
  • .lane/checks/bin/check-affected: 13 passed, 6 skipped over 2 changed files (ran before and after tidy)
  • fresh-context review subagent, given the pre-change argument table for every append_decision call: confirmed every decision passes the same 11 values in the same order, probes run under the same conditions, the Python stdout/stderr/exit codes are unchanged (non-dict actions and unknown ops…
  • grep of repo-fleet-hygiene tests for append_decision, phase( and ALLOWED: no test asserts on the changed source text
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42884770773

Left out: the items under Not verified.

Related

#14709

Merge-Risk: max=MEDIUM demote=false head=7eda1d67bee63053b2b53deac86acfc7f75b9e6c rubric=8.3.5 rater=claude-opus-5-5 checker=claude-opus-5-5

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 7eda1d67bee63053b2b53deac86acfc7f75b9e6c: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15167, no security issues found

This PR refactors plugins/repo-fleet-hygiene/skills/apply/scripts/apply-plan.sh and adds a changelog fragment. The script deletes branches and worktrees, so I checked whether every fail-closed safety check still behaves as before. It does.

What I checked

  • New decide() helper. It gets phase, op, canonical, ref, kind, target and expected through bash's dynamic scoping. In refresh_branch_delete and refresh_worktree_cleanup those are the callers' own local declarations (L522, L573). In the unknown-operation arm they come from the loop's read (L787). Every call I compared passes the same values in the same order as before. The two "missing headRefOid" calls used to pass a literal "" for expected; that branch only runs when expected is already empty, so the value is the same.
  • refresh_worktree_cleanup return-chain to elif chain. The order is unchanged: HEAD unreadable, then drift against the worktree HEAD, then drift against the branch tip, then locked, then dirty or unpushed. remove-worktree-then-branch is still reachable only after every one of those checks passes.
  • Embedded Python.
    • PHASES and ALLOWED_KINDS give the same results as the old if-chains.
    • An unknown op still exits 2 before any targets are read.
    • Only delete-remote-branches maps to REMOTE_KINDS, so a merged-remote-branch finding is still rejected.
    • The rewritten finding_index condition is logically the same as the old if/elif.
    • The output row is the same FS.join of the same 11 fields, each passed through clean().
  • Untouched paths. Remote-delete gating (refresh_remote_delete, remote_names_audited_repo, remote_pr_state_ok) is not changed by this diff.

None of the changed files match a trusted-path glob. There are no manifest, workflow, token or trust-control changes, and no instruction-surface deletions. The PR context file contains no embedded directives.

Files read: both listed files, every hunk.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 7eda1d67bee63053b2b53deac86acfc7f75b9e6c: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #15167, refactor(repo-fleet-hygiene): simplify apply-plan.sh decision recording

No findings. I read every hunk of both changed files and checked the result against the head file.

What I checked to confirm behavior is unchanged

  • decide() helper (apply-plan.sh:516-519): Bash scoping is dynamic, so decide reads phase/op/canonical/ref/kind/target/expected from the caller. That is the locals of refresh_branch_delete/refresh_worktree_cleanup (L522, L573), or the loop globals for the unknown operation arm (L787, L800). Every call passes the same 11 values, in the same order, as the old append_decision call:
    • The two plan evidence missing headRefOid sites used to pass "" for expected. They now pass "$expected", which is empty on that branch ([[ -z "$expected" ]]), so the result is the same.
    • worktree HEAD unreadable still records an empty live OID ("" passed explicitly at L621).
  • elif chain in refresh_worktree_cleanup (L620-633): it runs the same probes in the same order, and each branch records exactly one decision. This matches the old if/return chain.
  • Embedded Python:
    • finding_index condition (L195): key not in idx or (oid and not idx[key][1]) is logically the same as the old if/elif.
    • PHASES.get(op, 9) and ALLOWED_KINDS.get(op): op is always str(...) (L232, L241), so the dict lookups cannot raise. BRANCH_KINDS/WORKTREE_KINDS/REMOTE_KINDS are defined before the tables (L142-149).
    • The output row (L324-325) keeps the field order that the Bash read at L787 expects.
  • Changelog fragment: bump: patch fits an internal refactor with no behavior change. No plugin manifest is touched, so there are no manifest items.

Context

  • The PR is Refs: #14709 and closes no issue, so there are no acceptance criteria to check.
  • Path rules skill-bodies-state-current-rules.md and cost-claims.md match the changed script. The only new prose is the decide comment, which breaks neither rule.
  • Neither file matches a trusted path. Nothing in the PR context reads as an instruction to this lane.
  • I did not run apply-plan.test.sh or shellcheck (this lane has no shell). The PR's verification list is the author's claim and I have not confirmed it.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 7eda1d67bee63053b2b53deac86acfc7f75b9e6c, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 7eda1d6

The verifier passed this head. The capture artifact holds the capture summary, which says whether the capture ran, and any screenshot or video that passed the mask check; this comment uploads no file.

Capture artifact: pr-capture-15167-7eda1d67bee63053b2b53deac86acfc7f75b9e6c, expires on 2026-12-10.

One comment per pull request, updated in place for each new head.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit fa945e8 Nov 10, 2026
64 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14709-42884770773-1 branch November 10, 2026 21:01
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit fa945e8bad964927efebe4144f4fc6048434cb01; later checks count it verified from this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants